home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2004 #9
/
Amiga Plus CD - 2004 - No. 09.iso
/
amigaplus
/
tools
/
dev_libs
/
feelin040718
/
sources
/
shade
/
area.c
next >
Wrap
C/C++ Source or Header
|
2004-08-03
|
10KB
|
355 lines
#include "Private.h"
/*** Private ***************************************************************/
static UBYTE defascheme[] = "s:1,s:3,s:7,s:7,s:8";
static UBYTE defischeme[] = "s:3,s:4,s:5,s:6,s:7";
SAVEDS void Shade_DrawActive(struct FeelinClass *Class,APTR Obj,ULONG Flags);
SAVEDS void Shade_DrawInactive(struct FeelinClass *Class,APTR Obj,ULONG Flags);
/*** Methods ***************************************************************/
///Shade_Setup
F_METHODM(ULONG,Shade_Setup,FS_Setup)
{
struct LocalObjectData *LOD = F_LOD(Class,Obj);
FObject win = Msg -> Render -> Window;
ULONG data;
data = F_Do(Msg -> Render -> Application,FM_Application_Resolve,"FP_Decorator_AScheme",defascheme);
if (!(LOD -> AScheme = (struct FeelinPalette *) F_Do(Msg -> Render -> Display,FM_CreateColorScheme,data,F_Get(_parent,FA_ColorScheme)))) return FALSE;
data = F_Do(Msg -> Render -> Application,FM_Application_Resolve,"FP_Decorator_IScheme",defischeme);
if (!(LOD -> IScheme = (struct FeelinPalette *) F_Do(Msg -> Render -> Display,FM_CreateColorScheme,data,F_Get(_parent,FA_ColorScheme)))) return FALSE;
/// Gadgets
if (F_Get(win,FA_Window_GadClose))
{
if (LOD -> Gad_Close = F_NewObj(GadgetClass -> Name,FA_Gadget_Type,FV_GadgetType_Close,FA_ContextHelp,"Close Window",TAG_DONE))
{
F_Do(Obj,FM_AddMember,LOD -> Gad_Close,FV_AddMember_Tail);
}
else return FALSE;
}
if (!(FF_SHADE_ZOOM_IS_ICONIFY & LOD -> Flags))
{
if (F_Get(win,FA_Window_GadIconify))
{
if (LOD -> Gad_Iconify = F_NewObj(GadgetClass -> Name,FA_Gadget_Type,FV_GadgetType_Iconify,FA_ContextHelp,"Iconify Application",TAG_DONE))
{
F_Do(Obj,FM_AddMember,LOD -> Gad_Iconify,FV_AddMember_Tail);
}
else return FALSE;
}
}
if (F_Get(win,FA_Window_GadDragbar))
{
if (LOD -> Gad_Dragbar = F_NewObj(GadgetClass -> Name,FA_Gadget_Type,FV_GadgetType_Dragbar,FA_ContextHelp,"Drag Window",TAG_DONE))
{
F_Do(Obj,FM_AddMember,LOD -> Gad_Dragbar,FV_AddMember_Tail);
}
else return FALSE;
}
if (F_Get(win,FA_Window_Resizable))
{
if (LOD -> Gad_Zoom = F_NewObj(GadgetClass -> Name,FA_Gadget_Type,FV_GadgetType_Zoom,FA_ContextHelp,"Zoom Window",TAG_DONE))
{
F_Do(Obj,FM_AddMember,LOD -> Gad_Zoom,FV_AddMember_Tail);
if (LOD -> Gad_Size = F_NewObj(GadgetClass -> Name,FA_Gadget_Type,FV_GadgetType_Size,FA_ContextHelp,"Resize Window",TAG_DONE))
{
F_Do(Obj,FM_AddMember,LOD -> Gad_Size,FV_AddMember_Tail);
}
else return FALSE;
}
else return FALSE;
}
if (F_Get(win,FA_Window_GadDepth))
{
if (LOD -> Gad_Depth = F_NewObj(GadgetClass -> Name,FA_Gadget_Type,FV_GadgetType_Depth,FA_ContextHelp,"Depth arrange Window",TAG_DONE))
{
F_Do(Obj,FM_AddMember,LOD -> Gad_Depth,FV_AddMember_Tail);
}
else return FALSE;
}
//+
/* Gadgets must be linked to the decorator BEFORE passing the method to
the superclass, otherwise children won't be setuped. */
if (F_SUPERDO())
{
LOD -> nn_window_active = (FNotifyHandler *) F_Do(_win,FM_Notify,FA_Window_Active,FV_Notify_Always,Obj,FM_Set,2,FA_Active,FV_Notify_Value);
LOD -> nn_window_title = (FNotifyHandler *) F_Do(_win,FM_Notify,FA_Window_Title, FV_Notify_Always,LOD -> Gad_Dragbar,FM_Draw,1,FF_Draw_Object);
LOD -> GadW = _font -> tf_YSize + _font -> tf_YSize / 3;
LOD -> GadH = _font -> tf_YSize;
_bl = 2 + TICKNESS;
_br = 2 + TICKNESS;
_bb = 2 + TICKNESS;
if (LOD -> Gad_Dragbar)
{
_bt = 2 + MAX(_font -> tf_YSize,LOD -> GadH + TITLEY1 + TITLEY2);
}
else
{
_bt = 2 + TICKNESS;
}
return TRUE;
}
return FALSE;
}
//+
///Shade_Cleanup
F_METHOD(void,Shade_Cleanup)
{
struct LocalObjectData *LOD = F_LOD(Class,Obj);
FObject gad;
if (_render)
{
F_Do(_win,FM_UnNotify,LOD -> nn_window_active); LOD -> nn_window_active = NULL;
F_Do(_win,FM_UnNotify,LOD -> nn_window_title); LOD -> nn_window_title = NULL;
if (LOD -> AScheme)
{
F_Do(_display,FM_DeleteColorScheme,LOD -> AScheme); LOD -> AScheme = NULL;
}
if (LOD -> IScheme)
{
F_Do(_display,FM_DeleteColorScheme,LOD -> IScheme); LOD -> IScheme = NULL;
}
}
F_SUPERDO();
while (gad = (FObject) F_Get(Obj,FA_Group_Tail))
{
F_DisposeObj(gad);
}
}
//+
///Shade_Layout
#define area_class_offset FC_Area_Offset
#define _gad_init FAreaData * gad_area_data = (FAreaData *)((ULONG)(gad) + area_class_offset)
#define _gad_box (gad_area_data -> Box)
#define _gad_x (_gad_box.x)
#define _gad_y (_gad_box.y)
#define _gad_w (_gad_box.w)
#define _gad_h (_gad_box.h)
F_METHOD(void,Shade_Layout)
{
struct LocalObjectData *LOD = F_LOD(Class,Obj);
WORD x1 = _x + 1,
y1 = _y + 1,
x2 = _x2;
FObject gad;
LOD -> LastDrawn = FV_Shade_LastDrawn_None;
if (F_Get(_win,FA_Window_Resizable))
{
if (!LOD -> Gad_Zoom || !LOD -> Gad_Size)
{
if (LOD -> Gad_Zoom = F_NewObj(GadgetClass -> Name,FA_Gadget_Type,FV_GadgetType_Zoom,FA_ContextHelp,"Zoom Window",TAG_DONE))
{
F_Do(Obj,FM_AddMember,LOD -> Gad_Zoom,FV_AddMember_Tail);
if (LOD -> Gad_Size = F_NewObj(GadgetClass -> Name,FA_Gadget_Type,FV_GadgetType_Size,FA_ContextHelp,"Resize Window",TAG_DONE))
{
F_Do(Obj,FM_AddMember,LOD -> Gad_Size,FV_AddMember_Tail);
}
// else return FALSE;
}
// else return FALSE;
}
}
else if (LOD -> Gad_Zoom || LOD -> Gad_Size)
{
F_DisposeObj(LOD -> Gad_Size); LOD -> Gad_Size = NULL;
F_DisposeObj(LOD -> Gad_Zoom); LOD -> Gad_Zoom = NULL;
}
if (LOD -> Gad_Dragbar)
{
if (!LOD -> Gad_Close && !LOD -> Gad_Iconify)
{
x1 += TICKNESS;
}
else
{
if (gad = LOD -> Gad_Close)
{
_gad_init;
_gad_x = x1 + TICKNESS;
_gad_y = y1 + TITLEY1;
_gad_w = LOD -> GadW;
_gad_h = LOD -> GadH;
x1 = TICKNESS * 2 + x1 + LOD -> GadW;
F_Do(gad,FM_Layout);
}
if (gad = LOD -> Gad_Iconify)
{
_gad_init;
_gad_x = x1 + TICKNESS;
_gad_y = y1 + TITLEY1;
_gad_w = LOD -> GadW;
_gad_h = LOD -> GadH;
x1 = TICKNESS * 2 + x1 + LOD -> GadW;
F_Do(gad,FM_Layout);
}
}
if (!LOD -> Gad_Zoom && !LOD -> Gad_Depth)
{
x2 -= TICKNESS;
}
else
{
if (gad = LOD -> Gad_Depth)
{
_gad_init;
_gad_x = x2 - TICKNESS - LOD -> GadW;
_gad_y = y1 + TITLEY1;
_gad_w = LOD -> GadW;
_gad_h = LOD -> GadH;
x2 = x2 - (TICKNESS * 2) - LOD -> GadW;
F_Do(gad,FM_Layout);
}
if (gad = LOD -> Gad_Zoom)
{
_gad_init;
_gad_x = x2 - TICKNESS - LOD -> GadW;
_gad_y = y1 + TITLEY1;
_gad_w = LOD -> GadW;
_gad_h = LOD -> GadH;
x2 = x2 - (TICKNESS * 2) - LOD -> GadW;
F_Do(gad,FM_Layout);
}
}
}
if (gad = LOD -> Gad_Size)
{
_gad_init;
_gad_x = _x2 - SIZE + 1; _gad_w = SIZE - 1;
_gad_y = _y2 - SIZE + 1; _gad_h = SIZE - 1;
F_Do(gad,FM_Layout);
}
if ((x2 - x1 - 2) < 0)
{
F_Set(LOD -> Gad_Close,FA_Hidden,TRUE);
F_Set(LOD -> Gad_Iconify,FA_Hidden,TRUE);
F_Set(LOD -> Gad_Zoom,FA_Hidden,TRUE);
F_Set(LOD -> Gad_Depth,FA_Hidden,TRUE);
if (gad = LOD -> Gad_Dragbar)
{
_gad_init;
_gad_x = _x + TICKNESS + 2;
_gad_y = y1;
_gad_w = _w - TICKNESS * 2 - 4;
_gad_h = LOD -> GadH + TITLEY1 + TITLEY2;
F_Do(gad,FM_Layout);
}
}
else
{
F_Set(LOD -> Gad_Close,FA_Hidden,FALSE);
F_Set(LOD -> Gad_Iconify,FA_Hidden,FALSE);
F_Set(LOD -> Gad_Zoom,FA_Hidden,FALSE);
F_Set(LOD -> Gad_Depth,FA_Hidden,FALSE);
if (gad = LOD -> Gad_Dragbar)
{
_gad_init;
_gad_x = x1 + 1;
_gad_y = y1;
_gad_w = x2 - x1 - 2;
_gad_h = LOD -> GadH + TITLEY1 + TITLEY2;
F_Do(gad,FM_Layout);
}
}
}
//+
///Shade_Show
F_METHOD(ULONG,Shade_Show)
{
struct LocalObjectData *LOD = F_LOD(Class,Obj);
LOD -> LastDrawn = FV_Shade_LastDrawn_None;
if (_render)
{
struct Window *osw;
F_Set(Obj,FA_Active,F_Get(_win,FA_Window_Active));
if (osw = (APTR) F_Get(_win,FA_Window))
{
if (LOD -> Gad_Close) osw -> Flags |= WFLG_CLOSEGADGET;
if (LOD -> Gad_Zoom) osw -> Flags |= WFLG_HASZOOM;
}
}
return F_SUPERDO();
}
//+
///Shade_Draw
F_METHODM(void,Shade_Draw,FS_Draw)
{
if (FF_Draw_Object & Msg -> Flags)
{
if (F_Get(Obj,FA_Active)) Shade_DrawActive (Class,Obj,Msg -> Flags);
else Shade_DrawInactive(Class,Obj,Msg -> Flags);
}
}
//+
///Shade_GoActive
F_METHOD(void,Shade_GoActive)
{
F_Draw(Obj,FF_Draw_Object);
}
//+
///Shade_GoInactive
F_METHOD(void,Shade_GoInactive)
{
F_Draw(Obj,FF_Draw_Object);
}
//+